'use strict';

module.exports = function (mongoose, Schema) {
    let schema = new Schema({
        iCode: {
            type: String,
            unique: true,
            required: true,
        },
        eCode: String,
        banKuai: String,
        name: String,
        pinyin: String,    //汉语全拼
        pinyinF: String,   //汉语拼音首字母
        status: Number,//审核状态，0保存，1待审，2通过，3不通过, 4发布，5删除
        desc: String,//描述
        stocks: Array,//相关个股
        isArtificial: Number,//是否是人工录入的
    }, {collection: 'theme', timestamps: true});

    schema.virtual('code')
        .get(function() {
            return this.eCode.substr(2, 6);
        });
    schema.index({eCode: 1});

    return mongoose.model('Theme', schema);
};

